package com.hb.trade.server.project.complaint.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hb.core.pojo.project.complaint.dto.ComplaintDTO;
import com.hb.core.pojo.project.complaint.dto.ComplaintReplyDTO;
import com.hb.core.pojo.project.complaint.entity.ComplaintReply;
import com.hb.core.pojo.project.complaint.mapper.ComplaintReplyMapper;
import com.hb.trade.server.project.complaint.service.ComplaintReplyService;
import com.hb.trade.server.project.complaint.service.ComplaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class ComplaintReplyServiceImpl extends ServiceImpl<ComplaintReplyMapper, ComplaintReply> implements ComplaintReplyService {
    @Autowired
    private ComplaintService complaintService;

    @Transactional
    @Override
    public boolean saveComplaintReply(ComplaintReplyDTO complaintReplyDTO){
        complaintReplyDTO.buildBaseData(1);
        // 保存回复的信息
        boolean saveResult = save(complaintReplyDTO);
        // 修改质疑问题的状态
        Long complaintId = complaintReplyDTO.getComplaintId();
        ComplaintDTO complaintDTO = new ComplaintDTO();
        complaintDTO.setId(complaintId);
        complaintDTO.setComplaintStatus(4);
        // 设置更新时间
        complaintDTO.buildBaseData(2);
        boolean updateResult = complaintService.updateById(complaintDTO);
        return true;
    }
}
